﻿
@{
    ///商品列表
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Wares</title>

    <link href="~/Content/BootStrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/BootStrap/css/bootstrap-theme.min.css" rel="stylesheet" />
    <link href="~/Content/BootStrap/css/docs.min.css" rel="stylesheet" />
    <link href="~/bootstrapvalidator-master/dist/css/bootstrapValidator.min.css" rel="stylesheet" />
    <link href="~/Scripts/layui/css/layui.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Content/BootStrap/js/bootstrap.min.js"></script>
    <script src="~/Content/BootStrap/js/docs.min.js"></script>
    <script src="~/bootstrapvalidator-master/dist/js/bootstrapValidator.min.js"></script>
    <script src="~/bootstrapvalidator-master/dist/js/language/zh_CN.js"></script>
    <script src="~/Scripts/layui/layui.js"></script>
</head>
<body>
    <div id="main" style="margin-top:10px;">
        @*  @Html.Action("_WaresSearch", "Wares")*@
        <div class="demoTable">
            根据(书籍编号、名称)搜索：
            <div class="layui-inline">
                <input class="layui-input" name="value" id="demoReload" autocomplete="off">
            </div>
            <button class="layui-btn" data-type="reload">搜索</button>
        </div>
        <table class="layui-hide" id="LAY_table_user" lay-filter="user"></table>
    </div>
    <script type="text/javascript">
        layui.use('table', function () {
            var table = layui.table;

            //方法级渲染
            table.render({
                elem: '#LAY_table_user'
                , url: '/Wares/GetWaresSale'
                , cols: [[
                     { field: 'WID', title: '书籍编号', width: 120, sort: true, fixed: true }
                    , { field: 'WName', title: '书籍名称', width: 150 }
                    , { field: 'SaleNum', title: '书籍销量(个)', width: 150, sort: true }
                    , { field: 'Stock', title: '库存(个)', width: 150, sort: true }
                    , { field: 'PPrice', title: '售价(元)', width: 150, sort: true }
                ]]
                , id: 'testReload'
                , page: true
                , height: 310
            });

            var $ = layui.$, active = {
                reload: function () {
                    var demoReload = $('#demoReload');

                    //执行重载
                    table.reload('testReload', {
                        page: {
                            curr: 1 //重新从第 1 页开始
                        }
                        , where: {
                            value: demoReload.val()
                        }
                    }, 'data');
                }
            };

            $('.demoTable .layui-btn').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
        });
        //当选择子类别时动态加载子类别内容
        $("#SCID").change(function () {
            var select = $(this).val();
            if (select > 0)
            {
                 $.ajax({
                    url: '@Url.Action("Getswinfo", "Wares")',
                    type: 'post',
                    dataType: 'json',
                    data: { CID: select },
                    success: function (data) {
                        if (data != null) {
                            $.each(data, function (i, item) {
                                $("#SCID").append("<option value='" + item.SCID + "'>" + item.SCName + "</option>");   //为Select追加一个Option(下拉项)
                            });
                        }
                    }
                });
            }
            WaresSearch();

        });
        //搜索
        $("#serch").click(function () {
            var WName = $("#WName").val();
            if (WName == "")
            {
                alert("商品名不能为空");
            }
            else
            {
                WaresSearch();
            }
        });
        
    </script>
</body>
</html>
